package cn.edu.javaweb.superServlet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.edu.javaweb.utils.DBUtil;



@WebServlet("/AddCollageAdmin")
public class AddCollageAdmin extends HttpServlet {
	 DBUtil db; //声明对象 一定要赋值  否则空指针异常
	 protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		 db=new DBUtil(); //建创对象 搭桥配置初始化
		    String foodname=request.getParameter("foodname");
		    String feature=request.getParameter("feature");
		    String material=request.getParameter("material");
		    String price=request.getParameter("price");
		    String picture=request.getParameter("picture");
		    String sql="insert into food(collagename,feature,material,price,picture,type) values('"+foodname+"','"+feature+"','"+material+"','"+price+"','"+picture+"','5')";
		    System.out.println(sql);
		    int result=db.update(sql);
		    PrintWriter out=response.getWriter();
		    response.sendRedirect("/MenuJDBC/SelectFood");
	}


	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		this.doGet(request, response); 
	}

}
